import warnings
from functools import wraps
import datetime, time

warn = warnings.warn

def now():
    return time.strftime('%Y%m%d%H%M%S', time.localtime())

def warn_old_fashion(msg: str):
    warn("old fashion implementation: {}".format(msg))


def unreachable(msg: str):
    """
    this code is unreachable

    """
    raise Exception("This function is not unreachable because {}".format(msg))


def not_implemented(msg: str):
    """
    this function is not implemented
    """
    raise NotImplementedError(msg)


def todo(msg: str):
    """
    this function is not implemented
    """
    raise NotImplementedError(msg)


def override(func):
    @wraps(func)
    def wrapper(self, *args, **kwargs):
        superobj = super(type(self), self)
        if not hasattr(superobj, func.__name__):
            warn("overide warning: super class {} doesn't has method {}".format(superobj, func.__name__))
        return func(self, *args, **kwargs)
    return wrapper


def mytest(func):
    """
    test func should not have in parameter
    """
    @wraps(func)
    def wrapper():
        rtn = func()
        if rtn == 0:
            print("test pass")
        else:
            print("test failed with code {}".format(rtn))
    return wrapper

@mytest
def test():
    class A:
        def fun(self):
            pass

    class B(A):
        @override
        def fun(self):
            pass

        @override
        def fun2(self):
            pass

    b = B()
    b.fun()
    b.fun2()

    return True


if __name__ == '__main__':
    test()
